package userConsole.servlet;

import org.json.JSONException;
import org.json.JSONObject;
import userConsole.service.SelectUserByNameOrPasswordService;
import userConsole.service.SelectUserByPasswordService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author weishen
 */
@WebServlet("/selectUserByNameOrPasswordServlet")
public class SelectUserByNameOrPasswordServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        String showCount = req.getParameter("showCount");
        String page = req.getParameter("page");
        try {
            JSONObject jsonObject = new SelectUserByNameOrPasswordService().selectUserByNameOrPassword(username,password,showCount,page);
            StaticPrint.print(resp,jsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
